package com.example.demo.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;

import java.util.concurrent.Future;

@Service
@Slf4j
public class AsyncService {


    @Async
    public String  addMemberActionAndEmail(){
      log.info("2");
      try {
          Thread.sleep(5000);
      }catch (Exception e){

      }
        log.info("3");
      return "";
    }


    @Async
    public Future<String> sendDataWithResult(){
        log.info("2");
        try {
            Thread.sleep(5000);
        }catch (Exception e){

        }
        log.info("3");
        return new AsyncResult<String>("返回结果");
    }
}
